import { formatDate } from '@/utils/formatTime'
import { TableColumns } from '@pureadmin/table'
import { DICT_TYPE } from '@/utils/dict'
import DictTag from '@/components/DictTag/src/DictTag.vue'

interface TableColumnList extends Array<TableColumns> {}

export function useTable() {
  const columns: TableColumnList = [
    { prop: 'id', label: 'ID', width: 80, align: 'center' },
    { prop: 'name', label: '规则名称', minWidth: 120, align: 'center' },
    {
      prop: 'tenantType',
      label: '规则类型',
      minWidth: 120,
      align: 'center',
      cellRenderer: ({ row }) => <DictTag type={DICT_TYPE.TENANT_IDENTITY} value={row.tenantType} />
    },

    {
      prop: 'createTime',
      label: '创建时间',
      minWidth: 180,
      align: 'center',
      formatter({ createTime }) {
        return formatDate(createTime)
      }
    },
    {
      label: '操作',
      fixed: 'right',
      minWidth: 168,
      align: 'center',
      slot: 'operation'
    }
  ]

  return {
    columns
  }
}
